package me.bcloud.web.servlet.manager;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import me.bcloud.web.service.JobConfigService;
import org.springframework.stereotype.Controller;

@Controller
public class OpenServlet extends HttpServlet {

	@Resource
	private JobConfigService jobConfigService;
	public void setJobConfigService(JobConfigService jobConfigService) {
		this.jobConfigService = jobConfigService;
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		int jobId=Integer.parseInt(req.getParameter("id"));
		boolean isOpen=Integer.parseInt(req.getParameter("open"))==1?true:false;
		jobConfigService.open(isOpen, jobId);
		resp.setContentType("text/html");
		resp.getOutputStream().write("yes".getBytes());
		
	}
}
